<template>
  <div class="app-container">
    <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
      <el-form-item label="时间" prop="login_date">
        <el-date-picker
          v-model="formInline.login_date"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="timestamp"
          :picker-options="pickerDayStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="操作人" prop="operator">
        <el-select v-model="formInline.operator" placeholder="请选择操作人">
          <el-option
            v-for="item in operatorList"
            :label="item.name"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作类别" prop="type">
        <el-select v-model="formInline.type" placeholder="请选择操作类别">
          <el-option
            v-for="item in consts.OPERATE_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <el-button @click="cancel('formInline')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {getAuditOperator} from "@/services/api/audit";
  import {form,pickerOption} from '@/build'

  export default {
    name: "form-operate-filter",
    mixins: [form,pickerOption],
    data() {
      return {
        operatorList:[],
        formInline: {
          login_date: '',
          type: '',
          operator: ''
        },
      }
    },
    methods: {
      handleFilter() {
        this.$emit('on-filter', this.formInline)
      },
      cancel(formName) {
        this.resetForm(formName)
        this.handleFilter()
      }
    },
    mounted(){
      this.bindGet(getAuditOperator,'operatorList',{
        format: data=> data.list
      })
      this.getAll()
    }
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
